
package system.base;

import framework.core.*;
import system.SelectManager;
import system.data.*;

/*
	Author    :Wing
	CreateTime:2008-02-20 17:44:59
*/
public class OutHead extends OutHeadBase 
{

//----system generated start----// 	
public OutHead() 
{
	
}

private static void delete(DBConnection con,String out_bill_code) throws Exception
{
	Conditions conditions = new Conditions();

	conditions.add(OUT_BILL_CODE,out_bill_code);
	
	delete(con,TABLE_NAME,conditions);
}
public static OutHead fetch()
{
	return new OutHead();
}
public static OutHead copy(OutHead srcObj)
{
	OutHead obj = fetch();
	obj.copyBase(srcObj);
	return obj;
}
public static OutHead fetch(DBConnection con,String id) throws Exception
{
    Conditions conditions = new Conditions();

    conditions.add(ID,id);
    
    return fetch(con,conditions);
}
public static OutHead fetch(DBConnection con,Conditions conditions) throws Exception
{
	DBResult result = null;
	try
	{
		result = DBEngine.doSelect(con,"select * from " + TABLE_NAME,conditions);
		java.sql.ResultSet rs = result.getRs();
		OutHead obj = null;
		if(rs.next())
		{
			obj = fetch(rs);
		}
		return obj;
	}
	finally
	{
		if(result!=null) result.clear() ;
	}
}
public static OutHead fetch(java.sql.ResultSet rs) throws Exception
{
	OutHead obj = new OutHead();
	obj.initObject(rs);
	return obj;
}
protected void getUnique(DBConnection con) throws Exception
{
		setId(DBEngine.getId(con));
}
//----system generated end----//



//----add by Wing start----//
public String viewBalanceFlag(DBConnection con) throws Exception
{
    return SelectManager.viewYesOrNoBalance(getBalanceFlag()+"");
}

public String viewOutType(DBConnection con) throws Exception
{
    Conditions cs = new Conditions();
    cs.add(InoutType.CODE,getOutType());
    InoutType obj = InoutType.fetch(con, cs);
    if (obj == null)
        return "";
    else
        return obj.viewName(con);
}

public static boolean IsCheckedOfWarehouseCode(String loginWarehouseCode,String warehouseCode) throws Exception
{
    boolean checked = false;
    if(loginWarehouseCode != null) {
        if (loginWarehouseCode.equals(warehouseCode)) return true;
    }
    return checked;
}

//----add by Wing end----//

//add by Jackey start --//
public String viewWarehouseName(DBConnection con) throws Exception
{
    String mReturn = "";
    Warehouse w = Warehouse.fetchByCode(con, getWarehouseCode());  
    if (w != null)
    {
        mReturn = w.getName();
    }
    return  mReturn;
}
// add by Jackey end

//add by Sindy start
public static OutHead fetchByOutBillId(DBConnection con,String id) throws Exception
{
    Conditions conditions = new Conditions();

    conditions.add(ID,id);
    
    return fetch(con,conditions);
}
//add by Sindy end

}

